package com.yunzhong.appointment.essentialinformation.service.impl;

import com.yunzhong.appointment.entity.Hospital;
import com.yunzhong.appointment.essentialinformation.service.IHostipalService;
import com.yunzhong.appointment.mapper.HospitalMapper;
import com.yunzhong.appointment.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * @author 王仁海
 * @author ThinkPad
 * @desc 医院简介模型层实现类
 */
@Service
public class HostipalServiceImpl implements IHostipalService {

    /**
     * 依赖注入医院简介Mapper接口
     */
    @Autowired
    private HospitalMapper hospitalMapper;

    @Override
    public List<Hospital> queryHostipal(PageData pd) {
        pd.setPageData(pd);
        System.out.println("pd-----------" + pd);
        return hospitalMapper.queryHostipal(pd);
    }

    @Override
    public Hospital queryById(String id) {
        return hospitalMapper.selectByPrimaryKey(id);
    }

    @Override
    public int delete(String[] ids) {
        int tiao = 0;
        for (int i = 0; i < ids.length; i++) {
            tiao = hospitalMapper.deleteByPrimaryKey(ids[i]);
        }
        return tiao;
    }

    @Override
    public int save(Hospital yyjj) {
        yyjj.setHospitalId(UUID.randomUUID().toString());
        return hospitalMapper.insertSelective(yyjj);
    }

    @Override
    public int edit(Hospital yyjj) {
        return hospitalMapper.updateByPrimaryKeySelective(yyjj);
    }
}
